﻿function checkCookieData(varUsername, varPassword) {
    varUsernameObj = document.getElementById("txtUsername");
    varPasswordObj = document.getElementById("txtPassword");
    if (varUsername != "") {
        varUsernameObj.style.backgroundImage = 'none';
    }
    else {
        varUsernameObj.style.backgroundImage = "url('../../Images/PaydImages/place_holder_username.png')";
    }
    if (varPassword != "") {
        varPasswordObj.style.backgroundImage = 'none';
    }
    else {
        varPasswordObj.style.backgroundImage = "url('../../Images/PaydImages/place_holder_password.png')";
    }
}
function checkUsername(self) {
    if (self.value.length > 0) {
        self.style.backgroundImage = 'none';
    }
    else {
        self.style.backgroundImage = "url('../../Images/PaydImages/place_holder_username.png')";
    }
}
function checkPassword(self) {
    if (self.value.length > 0) {
        self.style.backgroundImage = 'none';
    }
    else {
        self.style.backgroundImage = "url('../../Images/PaydImages/place_holder_password.png')";
    }
}

function validate_thai_citizen_id(id) {
    var b = 0;
    if (id.length < 13) return false;
    checksum = id.substring(12, 13);
    for (var i = 0; i < 12; i++) {
        b += parseInt(id.substring(i, i + 1)) * (13 - i);
    }
    tmp = 11 - (b % 11);
    switch (tmp) {
        case 11: check = 1; break;
        case 10: check = 0; break;
        default: check = tmp;
    }
    return (check == checksum);
}

function checkIdCard(id) {
    if (id.length != 13) return false;
    for (i = 0, sum = 0; i < 12; i++)
        sum += parseFloat(id.charAt(i)) * (13 - i); if ((11 - sum % 11) % 10 != parseFloat(id.charAt(12)))
        return false; return true;
}